<?php
namespace jy_qiuyuyue;
defined('BY_JYA') or exit('error');
/*
	工具类
*/
class model extends \plugin{
	public function get_area_code($area,$district=false,$street=false){
		$address=$area['province'];
		if($area['city']){
			$address.=' '.$area['city'];
		}
		if($area['district'] && $district){
			$address.=' '.$area['district'];
		}
		if($area['street'] && $street){
			$address.=' '.$area['street'];
		}
		$area_code=pdo_getcolumn('core_area',array('address'=>$address),'code');
		$data=array(
			'area_code'=>$area_code,
			'address'=>$address,
			'title'=>$area['street'],
		);
		return $data;
	}
	public function check_settime($postdata){
		if(!$postdata['id']){
			return true;
		}
		$params=array('day'=>$postdata['onday'],'serve_id'=>$postdata['serveid'],'status'=>array(1,2,4));
		$num=pdo_count('jy_qiuyuyue_server_order',$params);
		if($num){
			exi('当天该课程，已有人下单不能再编辑时间了！','error');
		}
		return true;
	}
}